﻿'/* Copyright (c) 2009, Graeme Grant (graeme@live.com.au)
' * All rights reserved.
' *
' * Redistribution and use in source and binary forms, with or without
' * modification, are permitted provided that the following conditions are met:
' *
' *   * Redistributions of source code must retain the above copyright
' *     notice, this list of conditions and the following disclaimer.
' * 
' *   * Redistributions in binary form must reproduce the above copyright
' *     notice, this list of conditions and the following disclaimer in the
' *     documentation and/or other materials provided with the distribution.
' * 
' *   * The name Graeme Grant may not be used to endorse or promote products
' *     derived from this software without specific prior written permission.
' *
' * THIS SOFTWARE IS PROVIDED BY GRAEME GRANT ``AS IS'' AND ANY
' * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
' * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
' * DISCLAIMED. IN NO EVENT SHALL Dr. WPF BE LIABLE FOR ANY
' * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
' * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
' * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
' * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
' * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
' * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
' */

Imports System.Xml.Serialization
Imports System.IO
Imports System.Drawing

<Serializable()> _
Public Class GiftGuide

#Region "Constructor"

    Public Sub New()

    End Sub

    Public Sub New(ByVal Details As Hashtable)
        ExtractDetails(Details)
    End Sub

    Friend Sub New(ByVal _json As String)
        ExtractDetails(CType(JSON.JsonDecode(_json), Hashtable)("results")(0))
    End Sub

#End Region

#Region "Public Properties"

    <XmlElement("guide_id")> _
    Private _guide_id As Integer
    Public Property GuideID() As Integer
        Get
            Return _guide_id
        End Get
        Set(ByVal value As Integer)
            _guide_id = value
        End Set
    End Property

    <XmlElement("creation_tsz_epoch")> _
    Private _creation_tsz As Date
    Public Property Creation() As Date
        Get
            Return _creation_tsz
        End Get
        Set(ByVal value As Date)
            _creation_tsz = value
        End Set
    End Property

    <XmlElement("description")> _
    Private _description As String
    Public Property Description() As String
        Get
            Return _description
        End Get
        Set(ByVal value As String)
            _description = value
        End Set
    End Property

    <XmlElement("lititlesting_id")> _
    Private _title As String
    Public Property Title() As String
        Get
            Return _title
        End Get
        Set(ByVal value As String)
            _title = value
        End Set
    End Property

    <XmlElement("display_order")> _
    Private _display_order As Integer
    Public Property DisplayOrder() As Integer
        Get
            Return _display_order
        End Get
        Set(ByVal value As Integer)
            _display_order = value
        End Set
    End Property

    <XmlElement("guide_section_id")> _
    Private _guide_section_id As Integer
    Public Property GuideSectionID() As Integer
        Get
            Return _guide_section_id
        End Get
        Set(ByVal value As Integer)
            _guide_section_id = value
        End Set
    End Property

    <XmlElement("guide_section_title")> _
    Private _guide_section_title As String
    Public Property GuideSectionTitle() As String
        Get
            Return _guide_section_title
        End Get
        Set(ByVal value As String)
            _guide_section_title = value
        End Set
    End Property

#End Region

#Region "Support Methods & Functions"

    Private Sub ExtractDetails(ByVal Details As Hashtable)

        _guide_id = JSON.ToInteger(Details("guide_id"))
        _creation_tsz = JSON.DecodeDateTime(Details("creation_tsz_epoch"))
        _description = Details("description")
        _title = Details("title")
        _display_order = JSON.ToInteger(Details("display_order"))
        _guide_section_id = JSON.ToInteger(Details("guide_section_id"))
        _guide_section_title = Details("guide_section_title")

    End Sub

#End Region

End Class

